<template>
  <a-drawer title="招生目录明细" wrapClassName="fullscreen" height="100%" placement="bottom" :closable="false" @close="handleCancel"
    :visible="addVisiable">
    <template v-if="infoIdx==0">
      <one-info ref="one" :disabledStop="false" :keyNum="mathRandom" :info='baseInfo' @getInfoValue='getInfoValue'></one-info>
    </template>
    <template v-else-if="infoIdx==1">
      <two-info ref="two" :disabledStop="false" :info='baseInfo'></two-info>
    </template>

    <div class="drawer-bootom-button" style="z-index:1">
      <div style="float:right">
        <a-button type="primary" @click="handlePrev" v-if="infoIdx>0">上一步</a-button>
        <a-button type="primary" @click="handleNext" v-if="infoIdx<1">下一步</a-button>
        <a-button type="primary" @click="handleCancel">关闭窗口</a-button>
      </div>
    </div>
  </a-drawer>
</template>

<script>
  import OneInfo from './infoModule/one.vue'
  import TwoInfo from './infoModule/two.vue'

  export default {
    components: {
      OneInfo,
      TwoInfo
    },
    props: {
      addVisiable: {
        default: false
      },
      keyNum:{
         default:""
      }
    },
    data() {
      return {
        loading: false,
        postParams: {},
        imageUrl: '',
        selectMenu: {
          yx: [] // 院系
        },
        // 当前所在信息节点
        infoIdx: 0,
        baseInfo: {},
        mathRandom:''
      }
    },
   
    created() {
      
    },
     watch:{
      keyNum(){
        this.mathRandom=this.keyNum
        this.baseInfo={}
      }
    },
    methods: {
      // 关闭
      handleCancel() {
        this.infoIdx = 0
        this.$emit('close')
        // switch (this.infoIdx) {
        //   case 0:
        //     this.$refs.one.onClose()
        //     break
        //   case 1:
        //     this.$refs.two.onClose()
        //     break
        // }
        this.baseInfo = {}
      },
      // 点击下一步出发函数
      getInfoValue(newData) {
        // 验证通过处理数据
        console.log(newData)
        if (newData) {
          if (newData.id) {
            this.$api.recruitstat.setUpBySpecialtyId(newData.id).then(res => {
              this.baseInfo = res.data
              this.baseInfo.zsSsszszyml = {
                "id": newData.id
              }
            })
          } else {
            this.baseInfo = newData
            this.baseInfo.zsSsszszyml = {
              "id": newData.zsSsszszyml.id
            }
          }

          this.infoIdx++

          // 验证不通过不跳转下一页
        } else {
          console.log('哈哈')
          // this.infoIdx++
        }
      },
      // 添加导师触发函数
      getDetailData(data) {
        this.baseInfo = Object.assign(data, this.baseInfo)
      },
      // 下一页
      handleNext() {
        switch (this.infoIdx) {
          case 0:
            this.$refs.one.GetInfo()
            break
          case 1:
            this.$refs.two.GetInfo()
            break
        }

      },
      // 上一页
      handlePrev() {
        this.infoIdx--
      },
      // 保存修改
      handleSave() {

      }
    }
  }
</script>

<style lang="less">
  .fullscreen {
    .ant-drawer-wrapper-body {
      height: 100%;
      overflow: auto;
    }
  }
</style>
